<?php
include("./PDO/PdoConnect.php"); //On inclut la connexion à la base de données.
include("./PDO/PdoTypeArt.php"); //On inclut les fonctions PDO (create / update etc...)
require("./class/TypeArt.php"); //On requiere le fichier.

if (isset($_GET['action']))
{
	$action = $_GET['action'];
}

switch ($action)
{
	case "ajouter": //On inclut la page pour ajouter une typeart.
            include("./page/typeart/ajouter.php");
            break;
	case "traitement_ajout": //On inclut la page qui insère la typeart en base.
            $typeart = new TypeArt();
            $typeart->setNomArt($_POST['NOMART']);
            
            
            $oPDO= new PdoTypeArt();
            $oPDO->create($typeart);
            break;
	case "lister":
            $oPDO = new PdoTypeArt();
            $lesTypeArt = $oPDO->readAll(); //ligne est un array contenant tous les typeart
            include("./page/typeart/lister.php");
            break;
        case "modifier":
            include("./page/typeart/modifier.php");
            break;
        case "traitement_modif":
            $typeart = new TypeArt();
            $typeart->setNomTypeArt($_POST['NOMART']);
            $typeart->setIdTypeArt($_POST['IDTYPEART']);
            
            
            $pdo = new PdoTypeArt();
            $pdo->update($typeart);
            break;
        case "supprimer":
            $typeart = new TypeArt();
            $typeart->setIdTypeArt($_GET['IDTYPEART']);
            $oPDO = new PdoTypeArt();
            $oPDO->delete($typeart);
            break;
}
